package com.atguigu.serviceBase;

import com.atguigu.commonutil.ApiResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Aug28-tlsjn
 * @date 2020-06-30 Tuesday 12:42
 * 统一的异常处理器类
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler({Exception.class})
    @ResponseBody
    public ApiResponse<String> error(Exception e) {
        return ApiResponse.failedInstance().setMessage("来自GlobalExceptionHandler" + e.getMessage()).setData(e.getMessage());
    }
}
